<?php

/*
	Class: Admin

	About: Author
		Jaybill McCarthy

	About: License
		<http://communit.as/docs/license>

	About: See Also
		<Cts_Controller_Action_Abstract>
		<Cts_Controller_Action_Admin>
*/
class AdminController extends  Cts_Controller_Action_Admin {

	/* Group: Instance Methods */

	/*
		Function: init
			Invoked automatically when an instance is created.
			For this class, does nothing other than initialize the parent object (calls init() on the parent instance).
	*/
	function init() {
        parent::init();
    }

	/* Group: Actions */

	/*
		Function: index
			The administration landing page. Currently does nothing. Template might contain welcome text.
	*/
    function indexAction() {
		$params = array('username' => $this->_identity->username);
		$additional = $this->_cts_plugin->doFilter($this->_mca, $params); // FILTER HOOK
		foreach ($additional as $key => $value) {
			$this->view->$key = $value;
		}
    }

	/*
		Function: serialize
	*/
	function serializeAction() {
		$request = new Cts_Request($this->getRequest());
		if ($this->getRequest()->isPost()) {
			$output = array();
			for ($i = 1; $i <= 7; $i++) {
				if ($request->{"value".$i} != "") {
					$output[] = $request->{"value".$i};
				}
			}
			$this->view->result = serialize($output);
		}
	}

	/*
		Function: serializeassociative
	*/
	function serializeassociativeAction() {
		$request = new Cts_Request($this->getRequest());
		if ($this->getRequest()->isPost()) {
			$output = array();
			for ($i = 1; $i <= 7; $i++) {
				if ($request->{"key".$i} != "") {
					$output[$request->{"key".$i}] = $request->{"value".$i};
				}
			}
			$this->view->result = serialize($output);
		}
	}

	/*
		Function: unserialize
	*/
	function unserializeAction() {
		$request = new Cts_Request($this->getRequest());
		if ($this->getRequest()->isPost()) {
			$this->view->results = unserialize($request->serialized_array);
		}
	}

}
